﻿using System;
using System.Collections.Generic;
using HK.Core.Common;
using HK.Core.Common.Data;
using HK.Core.Common.Protocol;
using HK.Core.Common.Protocol.Data;
using HK.Editor.Defines.Data;
using HK.Editor.GUIEx.Protocol.Data;
using HK.Editor.GUIEx.Protocol.TreeView.Data;
using HK.Editor.GUIEx.Protocol.Window;
using UnityEditor;

namespace HK.Editor.Defines.Protocol.Data
{
    /// <summary>
    /// 接口 : 宏定义
    /// </summary>
    public interface IDefineInfo : ITreeBranch, IListElement
    {
        /// <summary>
        /// 是否勾选
        /// </summary>
        bool Selected { get; set; }
        
        /// <summary>
        /// 宏
        /// </summary>
        string Define { get; set; }
        
        /// <summary>
        /// Tips
        /// </summary>
        string Tips { get; set;}
        
        /// <summary>
        /// 值
        /// </summary>
        int Value { get; set; }
        
        /// <summary>
        /// iOS
        /// </summary>
        bool iOS { get; set; }
        
        /// <summary>
        /// Android
        /// </summary>
        bool Android { get; set; }
        
        /// <summary>
        /// Ps4
        /// </summary>
        bool Ps4 { get; set; }
        
        /// <summary>
        /// Ps5
        /// </summary>
        bool Ps5 { get; set; }
        
        /// <summary>
        /// XboxOne
        /// </summary>
        bool XboxOne { get; set; }
        
        /// <summary>
        /// Pc
        /// </summary>
        bool Pc { get; set; }
        
        /// <summary>
        /// 详细信息
        /// </summary>
        string Detail { get; }
        
        /// <summary>
        /// 新宏标志位
        /// </summary>
        bool New { get; }
        
        /// <summary>
        /// 设定宏状态
        /// </summary>
        /// <param name="iPlatform">Platform</param>
        /// <param name="iOnOrOff">On/Off</param>
        /// <returns>true:有变更; false:无变更;</returns>
        bool SetStatus(PlatformType iPlatform, bool iOnOrOff);

        /// <summary>
        /// 克隆
        /// </summary>
        /// <returns>宏定义</returns>
        IDefineInfo Clone();
    }

    /// <summary>
    /// 接口 : 宏定义列表
    /// </summary>
    /// <typeparam name="TDefines">宏列表类型</typeparam>
    /// <typeparam name="TDefine">宏类型</typeparam>
    public interface IDefinesData<TDefines, TDefine> : IWindowData, IListJsonData<TDefine>
        where TDefines : ListJsonData<TDefines, TDefine>
        where TDefine : DefineInfo, IEquatable<TDefine>
    {
        
        /// <summary>
        /// 宏定义列表
        /// </summary>
        List<TDefine> Defines { get; }
        
        /// <summary>
        /// 重置宏设定
        /// </summary>
        /// <param name="iDefines">宏列表详细信息</param>
        /// <param name="iTargetGroup">目标平台类型</param>
        /// <returns>true:有变更; false:无变更;</returns>
        bool ResetDefines(string iDefines, BuildTargetGroup iTargetGroup);

        /// <summary>
        /// 设定宏
        /// </summary>
        /// <param name="iDefine">宏</param>
        /// <param name="iTargetGroup">目标平台类型</param>
        /// <param name="iOnOrOff">On/Off</param>
        /// <returns>true:有变更; false:无变更;</returns>
        bool SetDefine(IDefineInfo iDefine, BuildTargetGroup iTargetGroup, bool iOnOrOff);

        /// <summary>
        /// 重置所有的Defines
        /// </summary>
        /// <param name="iTargetGroup">目标平台类型</param>
        /// <param name="iOnOrOff">On/Off</param>
        void ResetAllDefines(BuildTargetGroup iTargetGroup, bool iOnOrOff);

        /// <summary>
        /// 追加宏.
        /// </summary>
        /// <param name="iDefines">宏定义列表</param>
        /// <param name="iTargetGroup">目标平台类型</param>
        /// <param name="iOnOrOff">On Or Off</param>
        /// <returns>true:有变更; false:无变更;</returns>
        bool AddDefines(string[] iDefines, BuildTargetGroup iTargetGroup, bool iOnOrOff);
        
        /// <summary>
        /// 追加宏.
        /// </summary>
        /// <param name="iDefine">宏定义列表</param>
        /// <returns>true:OK; false:NG;</returns>
        bool AddDefine(IDefineInfo iDefine);

        /// <summary>
        /// 保存宏
        /// </summary>
        /// <param name="iDefine">宏定义列表</param>
        /// <returns>true:有变更; false:无变更;</returns>
        bool SaveDefine(IDefineInfo iDefine);

        /// <summary>
        /// 删除宏
        /// </summary>
        /// <param name="iDefine">宏定义列表</param>
        /// <returns>true:OK; false:NG;</returns>
        bool DelDefine(IDefineInfo iDefine);

        /// <summary>
        /// 应用
        /// </summary>
        void Apply();
    }
}
